<?php
class ProductRelatedSaveEditAction extends AdminAction
{
	public function __construct()
	{
		parent::__construct();
		$this->responseType = 'json';
	}
	
	protected function afterConstruct()
	{
		$this->parseDtds('productrelated','edit');
	}
	
	public function execute()
	{
		$id				= $this->context->post('id');
		$data			= $this->getValidData();
		
		$prService		= new ProductRelatedService();
		if(is_numeric($id) && $id>0)
		{
			$prService->update($id,$data);
			$this->code	= 200;
		}
		else
		{
			$id	= $prService->add($data);
			if($id)
			{
				$this->code	= 200;
			}
			else
			{
				$this->code	= 400;
			}
		}
	}
}
